import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:yt_devops/resources/resources.dart';
import 'package:yt_devops/utils/enums.dart';

class SiteModel {
  /// 站点id
  int? siteId;
  int? collectFlag;

  /// 站点名称
  String? name;

  SiteStatusType? status;

  ///站点地址
  String? address;

  /// 站点logo
  String? logo;

  /// 当日光伏总容量
  double? photovoltaicInstalledCapacity;

  /// 当日储能总量
  double? energyStorageCapacity;

  /// 充电桩总功率
  double? chargingStationCapacity;

  ///  储能额定功率 单位：kW
  double? energyStoragePower;
  double? longitude;
  double? latitude;
  String? deliveryTime;
  // 1光伏站点 2儲能站点  、3充电站点，   光储站点，"12"，（”光储充站点”，"123"），（儲沖站点，23) 光充站点13
  String? energyOptions;
  String? monetaryUnitName;//站点货币单位
  // 运行天数
  int? operationDays;

  SiteModel(
      {this.siteId,
      this.collectFlag,
      this.name,
      this.address,
      this.logo,
      this.status,
      this.chargingStationCapacity,
      this.energyStoragePower,
      this.photovoltaicInstalledCapacity,
      this.energyStorageCapacity,
      this.latitude,
      this.longitude,
      this.deliveryTime,
        this.monetaryUnitName,
      this.energyOptions,
      this.operationDays});

  factory SiteModel.fromJson(Map<String, dynamic> json) => SiteModel(
        siteId: json['siteId'],
        collectFlag: json['collectFlag'],
        name: json['name'],
        address: json['address'],
        logo: json['logo'],
        status: $enumDecodeNullable($SiteStatusTypeEnumMap, json['status']),
        photovoltaicInstalledCapacity: json['photovoltaicInstalledCapacity'],
        chargingStationCapacity: json['chargingStationCapacity'],
        energyStoragePower: json['energyStoragePower'],
        energyStorageCapacity: json['energyStorageCapacity'],
        latitude: json['latitude'],
        longitude: json['longitude'],
        deliveryTime: json['deliveryTime'],
        energyOptions: json['energyOptions'],
    monetaryUnitName: json['monetaryUnitName'],
        operationDays: json['operationDays'],
      );

  // 1光伏站点 2儲能站点  、3充电站点，   光储站点，"12"，（”光储充站点”，"123"），（储充站点，23) 光充站点13
  // List<SiteListItem> get siteListIconList {
  //   if(energyOptions.toString() == '1'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.sitePvChargeIcon,
  //         photovoltaicInstalledCapacity?.toString() ?? '0',
  //         'kWp',
  //         0,
  //       ),
  //     ];
  //   }else if(energyOptions.toString() == '2'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.siteLoadChargeIcon,
  //         '${energyStoragePower?.toString() ?? '0'}kW/${energyStorageCapacity?.toString() ?? '0'}',
  //         'kWh',
  //         1,
  //       ),
  //     ];
  //   }else if(energyOptions.toString() == '3'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.siteEvChargerIcon,
  //         '${energyStoragePower?.toString() ?? '0'}kW/${energyStorageCapacity?.toString() ?? '0'}',
  //         'kWh',
  //         2,
  //       ),
  //     ];
  //   }else if(energyOptions.toString() == '12'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.sitePvChargeIcon,
  //         photovoltaicInstalledCapacity?.toString() ?? '0',
  //         'kWp',
  //         0,
  //       ),
  //       SiteListItem(
  //         ImageAssets.siteLoadChargeIcon,
  //         '${energyStoragePower?.toString() ?? '0'}kW/${energyStorageCapacity?.toString() ?? '0'}',
  //         'kWh',
  //         1,
  //       ),
  //     ];
  //   }else if(energyOptions.toString() == '13'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.sitePvChargeIcon,
  //         photovoltaicInstalledCapacity?.toString() ?? '0',
  //         'kWp',
  //         0,
  //       ),
  //       SiteListItem(
  //         ImageAssets.siteLoadChargeIcon,
  //         chargingStationCapacity?.toString() ?? '0',
  //         'kW',
  //         2,
  //       ),
  //     ];
  //   }else if(energyOptions.toString() == '23'){
  //     return [
  //       SiteListItem(
  //         ImageAssets.siteLoadChargeIcon,
  //
  //         '${energyStoragePower?.toString() ?? '0'}kW/${energyStorageCapacity?.toString() ?? '0'}',
  //         'kWh',
  //         2,
  //       ),
  //       SiteListItem(
  //         ImageAssets.siteEvChargerIcon,
  //         chargingStationCapacity?.toString() ?? '0',
  //         'kW',
  //         1,
  //       ),
  //
  //     ];
  //   }else{
  //     return [
  //       SiteListItem(
  //         ImageAssets.sitePvChargeIcon,
  //         photovoltaicInstalledCapacity?.toString() ?? '0',
  //         'kWp',
  //         0,
  //       ),
  //       SiteListItem(
  //         ImageAssets.siteEvChargerIcon,
  //         chargingStationCapacity?.toString() ?? '0',
  //         'kW',
  //         1,
  //       ),
  //       SiteListItem(
  //         ImageAssets.siteLoadChargeIcon,
  //
  //         '${energyStoragePower?.toStringAsFixed(0) ?? '0'}kW/${energyStorageCapacity?.toStringAsFixed(0) ?? '0'}',
  //         'kWh',
  //         2,
  //       ),
  //     ];
  //   }
  //
  // }
}

class SiteListRequestParams {
  /// 站点名称
  String? siteName;

  /// 站点状态
  int? status;

  /// 站点类型：
  /// 都没有=0 光储充全有 = 123 仅有储能 = 2 有储充两种 =32 有光储两种 = 12
  List<String>? energyOptions;

  /// 交付时间开始时间 2023-02-09 00:00:00
  String? startTime;

  /// 交付时间结束时间 2023-08-09 23:59:59
  String? endTime;

  /// 站点地址
  String? address;

  /// 页数
  int current;

  /// 条数
  int pageSize;

  SiteListRequestParams({
    this.siteName = "",
    this.status = 2, // 0-正常 1-故障 2-全部
    this.energyOptions = const [],
    this.startTime = "",
    this.endTime = "",
    this.address = "",
    this.current = 1,
    this.pageSize = 10,
  });
}

enum InfoType {
  text,
  address,
  img,
}

class SiteListItem {
  String? label;
  String? value;
  String? unit;
  int? productType;
  TextStyle? valueTextStyle;
  final InfoType? type;

  SiteListItem(
    this.label,
    this.value,
    this.unit,
    this.productType, {
    this.valueTextStyle,
    this.type = InfoType.text,
  });
}
